#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h> 
#include <stdlib.h>
#include <assert.h>
#include "app_platform/cntl_info.h"
#include "employeedao.h"


#include "c2cplatform/component/dal/dal_set.h"
#include "c2cent/storage/mysqlstorage.h"
#include "c2cplatform/component/dal/db_operator_mysql_set.h"

using namespace c2cplatform::component::dal;
using namespace c2cent::storage;

using namespace erp::employee::dao;

CPP_SELF_DEFINE_START
/**
*  请在这里增加自定义的成员变量和函数及其他内容，否则无法合并代码
**/
#include "employeedao_enum.h"
#include "erp/comm/erp_macro_define.h"
#include "erp/comm/erp_errno_define.h"
#include "erp/gis/comm/erp_gis_define.h"

#define DB_ROLE_NAME_Employee  "erp_jansen_test"

using namespace c2cent::library::wtimeelf;
using namespace c2cent::library::wwlog;
using namespace erp::comm;
using namespace erp::gis::comm;

CItilGroup CEmployeeDao::m_oGetEmployee_Group(GETEMPLOYEE_REQ ,GETEMPLOYEE_ERR,GETEMPLOYEE_RSP,GETEMPLOYEE_DEF);
CItilGroup CEmployeeDao::m_oAddEmployee_Group(ADDEMPLOYEE_REQ ,ADDEMPLOYEE_ERR,ADDEMPLOYEE_RSP,ADDEMPLOYEE_DEF);
CItilGroup CEmployeeDao::m_oUpdateEmployee_Group(UPDATEEMPLOYEE_REQ ,UPDATEEMPLOYEE_ERR,UPDATEEMPLOYEE_RSP,UPDATEEMPLOYEE_DEF);
CItilGroup CEmployeeDao::m_oDeleteEmployee_Group(DELETEEMPLOYEE_REQ ,DELETEEMPLOYEE_ERR,DELETEEMPLOYEE_RSP,DELETEEMPLOYEE_DEF);

CPP_SELF_DEFINE_END

/**
 *构建函数
 */
CEmployeeDao::CEmployeeDao(enum DeployMethod method)
{

}

/**
 *析构函数
 */
CEmployeeDao::~CEmployeeDao()
{

}


/**
 *每一次服务请求时，container都会调用此方法来清空数据
 */
void  CEmployeeDao::Reset()
{
	m_dwOperatorUin=0;
    m_dwSceneId=0;
    m_strMachineKey="";
    m_strSource="";
}


int  CEmployeeDao::Initialize(IUserDefineCntl* pCntl)
{
	int iRetCode = 0;

	uint32_t dwLogSwitch=WLOG_OPEN|WLOG_KEY_OPEN|WLOG_ERR_OPEN;
	uint32_t dwCanLogRemote = 0;
	std::string strLogModule="dao_employee";

	std::cout<<"File:"<<__FILE__<<" Complie Date: "<<__DATE__<<" "<<__TIME__<<std::endl;

	 if(CDAL_SET->Initialize() != 0)
	 {
		 printf("CDAL_SET Init Failed, %s\n", CDAL_SET->getLastErrMsg());
		 return -1;
	 }

	 GetUintConfig(LogSwitch);
	 GetStringConfig(LogModule);
	 GetUintConfig(CanLogRemote);

	 // 初始化日志
	 if( C2C_WWLOG->QuickInitForAPP2(strLogModule.c_str(),B2B2CWW_LOG_APP_FILE_PATH, dwCanLogRemote, dwLogSwitch)!= 0)
	  {
		 std::cerr << "C2C_WWLOG->QuickInitForAPP2 Failed" << std::endl;
		 return -1;
	  }
	 C2C_WW_LOG("C2C_WWLOG->QuickInitForAPP2 OK!");

	 return iRetCode;
}


/**
 *
 *  根据ID获取员工信息
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景id，必填   [in]
 *@param EmployeeFilterDdo employeeFilter: 过滤器，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param Map employees: 员工信息  	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CEmployeeDao::GetEmployeeById(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				const erp::employee::ddo::CEmployeeFilterDdo& oEmployeeFilter,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::map<uint32_t,erp::employee::ddo::CEmployeeDdo >& mapEmployees,
				std::string& strOutReserve
	)
{
	int iRetCode = 0;
	//TODO:业务代码
	uint16_t iSetId = 0;
	uint32_t dwTime = 0;
	m_dwOperatorUin=rCntlInfo.getOperatorUin();
    m_dwSceneId=dwSceneId;
    m_strMachineKey=strMachineKey;
    m_strSource=strSource;

    C2C_WW_LOG("GetAReq %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
                    m_dwOperatorUin, strMachineKey.c_str(), strSource.c_str(), dwSceneId);

    //打印性能日志的同时进行接口的itil上报
    C2C_TIME_ELF_ITIL oWTimeElf(C2C_WWLOG,__FUNCTION__,&iRetCode,&m_oGetEmployee_Group);

    c2cent::storage::CMySqlStorage oStorage(CDAL_SET->GetDBOperator(rCntlInfo.getCmdId(),
    		                                rCntlInfo.getOperatorUin(), DB_ROLE_NAME_Employee, "t_employee",iSetId, true));
    std::stringstream ssSql;
    std::stringstream ssSqlWhere;

    ssSql <<"select FEmployeeId,FEmployeeName,FEmployeeEnglishName,FEmployeeStatus,FEmployeeProperty,";
    ssSql <<" FEmployeeType,FEmployeeSex,UNIX_TIMESTAMP(FEmployeeAddTime) AS ADDTIME,UNIX_TIMESTAMP(FEmployeeLastUpdateTime) AS UPDATETIME from";
    ssSql << " " << CDAL_SET->GetTableName(iSetId, 0, DB_ROLE_NAME_Employee, "t_employee").c_str();

    if(oEmployeeFilter.IsIdListSet()){
    	std::set<uint32_t> idList = oEmployeeFilter.GetIdList();
    	ssSql<< " where FEmployeeId in (";
    	for(std::set<uint32_t>::const_iterator it=idList.begin();it!=idList.end();it++)
    	{
    		if(it!=idList.begin())
    		{
    			ssSql<<","<< *it;
    		}
    		else
    		{
    			ssSql<< *it;
    		}
    	}
    	ssSql << ')';
    }
    else{
    	bool bHasPre=false;

    	if(oEmployeeFilter.IsEmployeeNameSet()&&!oEmployeeFilter.GetEmployeeName().empty()){
        	if(bHasPre)
        	{
        		ssSqlWhere<<" and";
        	}
        	ssSqlWhere<<" FEmployeeName like '%"<<oEmployeeFilter.GetEmployeeName()<<"%'";
    		bHasPre=true;
    	}

    	if(oEmployeeFilter.IsEmployeeEnglishNameSet()&&!oEmployeeFilter.GetEmployeeEnglishName().empty())
    	{
    		if(bHasPre)
			{
    			ssSqlWhere<<" and";
			}
    		ssSqlWhere<<" FEmployeeEnglishName like '%"<<oEmployeeFilter.GetEmployeeEnglishName()<<"%'";
    		bHasPre=true;
    	}

    	if(oEmployeeFilter.IsEmployeeStatusSet()&&oEmployeeFilter.GetEmployeeStatus().size()!=0)
    	{
    		if(bHasPre)
			{
    			ssSqlWhere<<" and";
			}
    		ssSqlWhere<<" FEmployeeStatus in (";
    		std::set<uint16_t> employeeStatus = oEmployeeFilter.GetEmployeeStatus();
    		for(std::set<uint16_t>::const_iterator it=employeeStatus.begin();it!=employeeStatus.end();it++)
    		{
    			if(it!=employeeStatus.begin())
    			{
    				ssSqlWhere <<","<< *it;
    			}
    			else
    			{
    				ssSqlWhere<< *it;
    			}
    			ssSqlWhere <<")";
    		}
    		bHasPre=true;
    	}

    	if(oEmployeeFilter.IsAddTimeBeginSet())
    	{
    		if(bHasPre)
			{
    			ssSqlWhere<<" and";
			}
    		ssSqlWhere << " FEmployeeAddTime>="<<oEmployeeFilter.GetAddTimeBegin();
    		bHasPre=true;
    	}
    	if(oEmployeeFilter.IsAddTimeEndSet())
    	{
    		if(bHasPre)
			{
    			ssSqlWhere<<" and";
			}
    		ssSqlWhere << " FEmployeeAddTime<="<<oEmployeeFilter.GetAddTimeEnd();
    	    bHasPre=true;
    	}

    	if(oEmployeeFilter.IsEmployeePropertyIncludeSet())
    	{
    		if(bHasPre)
			{
    			ssSqlWhere<<" and";
			}
    		if(oEmployeeFilter.GetEmployeePropertyOption()==1)
    		{
        		ssSqlWhere << " FEmployeeProperty&"<<(oEmployeeFilter.GetEmployeePropertyInclude()).to_ulong();
        		bHasPre=true;
    		}
    		else
    		{
        		ssSqlWhere << " ~FEmployeeProperty"
        				<< "&" <<(oEmployeeFilter.GetEmployeePropertyInclude()).to_ulong()
        				<< "^" <<(oEmployeeFilter.GetEmployeePropertyInclude()).to_ulong();
        		bHasPre=true;
    		}
    	}
    	else if(oEmployeeFilter.IsEmployeePropertyExcludeSet())
    	{
    		if(bHasPre)
			{
    			ssSqlWhere<<" and";
			}
    		ssSqlWhere << " ~FEmployeeProperty&"<<(oEmployeeFilter.GetEmployeePropertyExclude()).to_ulong();
    		bHasPre=true;
    	}

    	/*if(oEmployeeFilter.IsExternSet())
    	{
    		std::map<std::string,std::string> mapExtern =oEmployeeFilter.GetExtern();
    		std::map<std::string,std::string>::const_iterator it=mapExtern.begin();
    		std::map<std::string,std::string>::const_iterator itEnd=mapExtern.end();
    		for(;it!=itEnd;it++)
    		{
    			if(it->first =="aa")
    			{

    			}
    		}
    	}*/

		if(bHasPre)
		{
			ssSql<<" where";
			ssSql<<ssSqlWhere.str();
		}
    }

    if(oEmployeeFilter.IsOrderTypeSet())
    {
    	switch(oEmployeeFilter.GetOrderType())
    	{
    	case ORDERTYPE_UPDATETIME_ASC:
    		ssSql<<" ORDER BY FEMPLOYEELASTUPDATETIME ";
    		break;
    	case ORDERTYPE_ADDTIME_DESC:
    		ssSql<<" ORDER BY FEMPLOYEEADDTIME DESC ";
    		break;
    	case ORDERTYPE_ADDTIME_ASC:
    		ssSql<<" ORDER BY FEMPLOYEEADDTIME ";
    		break;
    	default:
    		ssSql<<" ORDER BY FEMPLOYEELASTUPDATETIME DESC ";
    		break;
    	}
    }

    ssSql<<" limit "<<oEmployeeFilter.GetPage()*oEmployeeFilter.GetPageSize()<<","<<oEmployeeFilter.GetPageSize();

    IResultSet& oRs = oStorage.QueryForResultSet(ssSql.str());

    C2C_WW_LOG_DEBUG("ExeSql Passed, Sql:%s", ssSql.str().c_str());

    if(!oRs.IsReady()) //db操作错误
     {
    	oRs.Close();
    	C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_SELECT_FAILED, "ExeSql Failed, Sql:%s", ssSql.str().c_str());
        C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_SELECT_FAILED, "ExeSql Failed, OpUin:%u MachineKey:%s Source:%s SceneId:%u",
                            rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId);
        C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
        return ERR_ERP_COMMON_DB_SELECT_FAILED;
      }

      if(!oRs.First() || oRs.GetRecordCount() == 0) //无记录
      {
    	  oRs.Close();
          C2C_WW_LOG_ERR(ERR_EMPLOYEE_GET_NONE, "ExeSql Failed, Sql:%s", ssSql.str().c_str());
          C2C_WW_LOG_ERR(ERR_EMPLOYEE_GET_NONE, "QuerySql not exist, "
                            "OpUin:%u MachineKey:%s Source:%s SceneId:%u",
                            rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId);
          C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
          return ERR_ERP_COMMON_DB_SELECT_FAILED;
      }

      do{
    	  erp::employee::ddo::CEmployeeDdo oEmployeeDdo;
    	  oEmployeeDdo.SetEmployeeId((uint32_t)oRs.GetUInt("FEmployeeId"));
    	  oEmployeeDdo.SetEmployeeName(oRs.GetString("FEmployeeName")?oRs.GetString("FEmployeeName"):"");
    	  oEmployeeDdo.SetEmployeeEnglishName(oRs.GetString("FEmployeeEnglishName")?oRs.GetString("FEmployeeEnglishName"):"");
    	  oEmployeeDdo.SetEmployeeStatus((uint16_t)oRs.GetUInt("FEmployeeStatus"));
          uint64_t ddwProperty=(uint64_t)oRs.GetBigUInt("FEmployeeProperty");
          oEmployeeDdo.SetEmployeeProperty(ddwProperty);
          oEmployeeDdo.SetEmployeeType((uint16_t)oRs.GetUInt("FEmployeeType"));
          dwTime =(uint32_t)oRs.GetUInt("ADDTIME");
          oEmployeeDdo.SetAddTime(dwTime);
          dwTime =(uint32_t)oRs.GetUInt("UPDATETIME");
          oEmployeeDdo.SetLastUpdatetime(dwTime);
          oEmployeeDdo.SetEmployeeSex((uint8_t)oRs.GetUInt("FEmployeeSex"));
          mapEmployees[(uint32_t)oRs.GetUInt("FEmployeeId")] = oEmployeeDdo;
        }while(oRs.Next());
        oRs.Close();

    return iRetCode;
}

/**
 *
 *  写入员工信息
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景id，必填   [in]
 *@param EmployeeDdo employee: 员工信息列表，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param EmployeeDdo employeeBack: 员工信息列表，必填  	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CEmployeeDao::AddEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				const erp::employee::ddo::CEmployeeDdo& oEmployee,
				const std::string& strInReserve,
				std::string& strErrmsg,
				erp::employee::ddo::CEmployeeDdo& oEmployeeBack,
				std::string& strOutReserve
	)
{
	int32_t iRetCode = 0;
	//TODO:业务代码
	uint16_t iSetId=0;
	m_dwOperatorUin=rCntlInfo.getOperatorUin();
    m_dwSceneId=dwSceneId;
    m_strMachineKey=strMachineKey;
    m_strSource=strSource;

    uint32_t dwEmployeeId = oEmployee.GetEmployeeId();

    C2C_WW_LOG("GetAReq %s OpUin:%u MachineKey:%s Source:%s SceneId:%u EmployeeId:%u", __FUNCTION__,
                    m_dwOperatorUin, strMachineKey.c_str(), strSource.c_str(), dwSceneId,dwEmployeeId);
	C2C_TIME_ELF_ITIL oWTimeElf(C2C_WWLOG,__FUNCTION__,&iRetCode,&m_oAddEmployee_Group);

    c2cent::storage::CMySqlStorage oStorage(CDAL_SET->GetDBOperator(rCntlInfo.getCmdId(),
    		                                rCntlInfo.getOperatorUin(), DB_ROLE_NAME_Employee, "t_employee",iSetId, true));
    std::stringstream sql;
    sql << " INSERT INTO ";
    sql << " " << CDAL_SET->GetTableName(0, 0, DB_ROLE_NAME_Employee, "t_employee").c_str();
    sql << " (FEmployeeId,FEmployeeName,FEmployeeEnglishName,FEmployeeStatus,FEmployeeProperty,FEmployeeType,";
    sql << " FEmployeeSex,FEmployeeAddTime,FEmployeeLastUpdateTime) VALUES( ";
    sql << " " << oEmployee.GetEmployeeId() << ", ";
    sql << " '" << oStorage.EscapeString(oEmployee.GetEmployeeName()) << "', ";
    sql << " '" << oStorage.EscapeString(oEmployee.GetEmployeeEnglishName()) << "',";
    sql << " " << oEmployee.GetEmployeeStatus() << ", ";
    sql << " " << (oEmployee.GetEmployeePropertyInclude()&~oEmployee.GetEmployeePropertyExclude()).to_ulong() << ", ";
    sql << " " << oEmployee.GetEmployeeType() << ", ";
    sql << " " << (uint32_t)oEmployee.GetEmployeeSex() << ", ";
    sql << " now(), now() ";
	sql << " ) ";

	C2C_WW_LOG_DEBUG("sql:%s", sql.str().c_str());//debug

	iRetCode = oStorage.Update(sql.str());

	C2C_WW_LOG_DEBUG("ExeSql Passed, Sql:%s", sql.str().c_str());

	if(iRetCode!=0)
	{//错误日志
		C2C_WW_LOG_ERR(iRetCode, "ExeSql Failed, Sql:%s", sql.str().c_str());
		C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_INSERT_FAILED, "ExeSql Failed, OpUin:%u MachineKey:%s Source:%s SceneId:%u EmployeeId:%u",
						rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId, dwEmployeeId);
		C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
		return ERR_ERP_COMMON_DB_INSERT_FAILED;
	}

	//操作没有操作到任何一条数据
	if(oStorage.GetAffectedRows()==0)
	{
		//错误日志
		C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_INSERT_FAILED, "ExeSql Insert None, Sql:%s", sql.str().c_str());
		C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_INSERT_FAILED, "ExeSql Failed, OpUin:%u MachineKey:%s Source:%s SceneId:%u EmployeeId:%u",
							rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId, dwEmployeeId);
		C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
		return ERR_ERP_COMMON_DB_INSERT_FAILED;
	}

	return iRetCode;
}


/**
 *
 *  修改员工信息
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景id，必填   [in]
 *@param EmployeeDdo employee: 员工信息列表，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param EmployeeDdo employeeBack: 员工信息列表，必填  	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CEmployeeDao::UpdateEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				const erp::employee::ddo::CEmployeeDdo& oEmployee,
				const std::string& strInReserve,
				std::string& strErrmsg,
				erp::employee::ddo::CEmployeeDdo& oEmployeeBack,
				std::string& strOutReserve
	)
{
	int32_t iRetCode = 0;
	//TODO:业务代码
	uint16_t iSetId=0;
	m_dwOperatorUin=rCntlInfo.getOperatorUin();
	m_dwSceneId=dwSceneId;
	m_strMachineKey=strMachineKey;
	m_strSource=strSource;
	C2C_WW_LOG("GetAReq %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
	                    m_dwOperatorUin, strMachineKey.c_str(), strSource.c_str(), dwSceneId);
	C2C_TIME_ELF_ITIL oWTimeElf(C2C_WWLOG,__FUNCTION__,&iRetCode,&m_oUpdateEmployee_Group);


	c2cent::storage::CMySqlStorage oStorage(CDAL_SET->GetDBOperator(rCntlInfo.getCmdId(),
    		                                rCntlInfo.getOperatorUin(), DB_ROLE_NAME_Employee, "t_employee",iSetId, true));
    std::stringstream sql;

    sql << "SELECT 1 FROM ";
    sql << " " << CDAL_SET->GetTableName(0, 0, DB_ROLE_NAME_Employee, "t_employee").c_str();
    sql << " WHERE FEMPLOYEEID = " << oEmployee.GetEmployeeId();
    sql << " LIMIT 1";

    C2C_WW_LOG_DEBUG("%s", sql.str().c_str());
    c2cent::storage::IResultSet& oRs = oStorage.QueryForResultSet(sql.str());

    if(oRs.IsReady() != true) //db操作错误
    {
        C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_SELECT_FAILED, "ExeSql Failed, Sql:%s", sql.str().c_str());
        C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_SELECT_FAILED, "ExeSql Failed, EmployeeId:%u",
        		oEmployee.GetEmployeeId());
        C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
        return ERR_ERP_COMMON_DB_SELECT_FAILED;
    }

    if (!oRs.First() || oRs.GetRecordCount() == 0) //db查询记录不存在
    {
    	C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_SELECT_FAILED, "EMPTY SET, Sql:%s", sql.str().c_str());
    	C2C_WW_LOG_ERR(ERR_ERP_COMMON_DB_SELECT_FAILED, "ExeSql Failed, EmployeeId:%u",
    	        		oEmployee.GetEmployeeId());
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return ERR_ERP_COMMON_DB_QUERY_FAILED;
    }
    else
    {
        //记录存在则更新记录
        sql.str(""); //清除上次sql
        sql << "UPDATE ";
        sql << " " << CDAL_SET->GetTableName(0, 0, DB_ROLE_NAME_Employee, "t_employee").c_str();
        sql << " SET FEMPLOYEELASTUPDATETIME=now() ";
        if(oEmployee.IsEmployeeNameSet())
        	sql << ", FEMPLOYEENAME='" << oStorage.EscapeString(oEmployee.GetEmployeeName())<<"' ";
        if(oEmployee.IsEmployeeEnglishNameSet())
        	sql << ", FEMPLOYEEENGLISHNAME='" << oStorage.EscapeString(oEmployee.GetEmployeeEnglishName())<<"' ";
        if(oEmployee.IsEmployeeStatusSet())
        	sql << ",FEmployeeStatus=" << oEmployee.GetEmployeeStatus();
        if(oEmployee.IsEmployeePropertyExcludeSet()&&oEmployee.IsEmployeePropertyIncludeSet())
        	sql << ",FEmployeeProperty=" << (oEmployee.GetEmployeePropertyInclude()&~oEmployee.GetEmployeePropertyExclude()).to_ulong();
        if(oEmployee.IsEmployeeSexSet())
        	sql << ",FEMPLOYEESEX=" << (uint32_t)oEmployee.GetEmployeeSex();
        if(oEmployee.IsEmployeeTypeSet())
        	sql << ",FEMPLOYEETYPE=" << oEmployee.GetEmployeeType();



        sql << " WHERE FEMPLOYEEID = " << oEmployee.GetEmployeeId();
    }

    iRetCode = oStorage.Update(sql.str());




	return iRetCode;
}

/**
 *
 *  删除员工信息
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景id，必填   [in]
 *@param EmployeeDdo employee: 员工信息列表，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CEmployeeDao::DeleteEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				const erp::employee::ddo::CEmployeeDdo& oEmployee,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::string& strOutReserve
	)
{
	int32_t iRetCode = 0;
	//TODO:业务代码
	uint16_t iSetId=0;
	m_dwOperatorUin=rCntlInfo.getOperatorUin();
	m_dwSceneId=dwSceneId;
	m_strMachineKey=strMachineKey;
	m_strSource=strSource;
	C2C_WW_LOG("GetAReq %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
	                    m_dwOperatorUin, strMachineKey.c_str(), strSource.c_str(), dwSceneId);
	C2C_TIME_ELF_ITIL oWTimeElf(C2C_WWLOG,__FUNCTION__,&iRetCode,&m_oDeleteEmployee_Group);

	c2cent::storage::CMySqlStorage oStorage(CDAL_SET->GetDBOperator(rCntlInfo.getCmdId(),
    		                                rCntlInfo.getOperatorUin(), DB_ROLE_NAME_Employee, "t_employee",iSetId, true));
    //std::stringstream sql;
    //sql << " " << CDAL_SET->GetTableName(0, 0, DB_ROLE_NAME_Employee, "t_employee").c_str();


	return iRetCode;
}
